package com.example.hwapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity implements OnClickListener{
	
	
	   TextView tvOut;
	   Button btnOk;
	   Button btnCancel;

	   public boolean onCreateOptionsMenu(Menu menu) {
		      // TODO Auto-generated method stub
		      
		      menu.add("menu1");
		      menu.add("menu2");
		      menu.add("menu3");
		      menu.add("menu4");
		      
		      return super.onCreateOptionsMenu(menu);
		    }
	   
	   
	   @Override
	    public boolean onOptionsItemSelected(MenuItem item) {
	      // TODO Auto-generated method stub
	      Toast.makeText(this, item.getTitle(), Toast.LENGTH_SHORT).show();
	      return super.onOptionsItemSelected(item);
	    }
	   
	   
	   /** Called when the activity is first created. */
	   @Override
	   public void onCreate(Bundle savedInstanceState) {
	     super.onCreate(savedInstanceState);
	     setContentView(R.layout.main);
	 
	     
	     tvOut = (TextView) findViewById(R.id.tvOut);
	     btnOk = (Button) findViewById(R.id.btnOk);
	     btnCancel = (Button) findViewById(R.id.btnCancel);
	 
	     OnClickListener oclBtn = new OnClickListener() {
	         @Override
	         public void onClick(View v) {
	        	 
	             switch (v.getId()) {
	             case R.id.btnOk:
	              
	               tvOut.setText("123123");
	               break;
	             case R.id.btnCancel:
	              
	               tvOut.setText("123123213");
	               break;
	             }
	   
	         }
	       };

	       //btnOk.setOnClickListener(oclBtn);
	       //btnCancel.setOnClickListener(oclBtn);

	       btnOk.setOnClickListener(this);
	       btnCancel.setOnClickListener(this);
	       
	       
	   }
	
	public void onClickIntentTest(View v){
		Intent intent = new Intent("android.intent.action.showdate");
		startActivity(intent);		
	}
	

	   public void onClickStart(View v) {
		   //tvOut.setText("123123");

		   Intent intent = new Intent(this, ActivityTwo.class);
		   startActivity(intent);
		   
		  }
	   
	   @Override
	   public void onClick(View v) {
		// TODO Auto-generated method stub
		 
        switch (v.getId()) {
        case R.id.btnOk:
         
          tvOut.setText("123");
          Toast.makeText(this, "123123", Toast.LENGTH_LONG).show();
          break;
        case R.id.btnCancel:
         
          tvOut.setText("12312312");
          break;
        }
	}
    
}
